------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  /Users/reillyj/GitHub/net_size_experiment/submission prep/NSX Log (Unformatte
> d).log
  log type:  text
 opened on:   4 Oct 2022, 11:33:50

. do "/var/folders/7k/twvnt7ps4kj5r7kxrnnxlw8h0000gn/T//SD98009.000000"

. *Title: NSX Reproduce 1.0.do
. *Authors: Jack Reilly, Jack Belk
. *Date: 10.4.22
. *Purpose: Reproduce Statistics & Figures in Reilly & Belk, "Political And Social Discuss
> ion Network Survey Items are Not Interchangeable" (JEPS)
. *Requires: 2020 CES - NCF Module Subset
. *Output: figures (to working directory)
. *Platform: Stata 17 on macOS 12.6, arm/M1 architecture
. 
. *Identify file paths
. *The script expects the data file, "CCES20_NCF_OUTPUT.sav", to be in this directory, and
>  will output graphics here as well
. cd "~/Desktop/working/NSX/reproduce"
/Users/reillyj/Desktop/working/NSX/reproduce

. import spss using "CCES20_NCF_OUTPUT_vv.sav", clear
note: invalid numeric format %
note: invalid numeric format %
note: invalid numeric format %
note: invalid numeric format %
(761 vars, 1,000 obs)

. keep teamweight NCF710A NCF710B newsint

. 
. *Final graphics in this paper utilize two nonstandard Stata packages.
. *First, the mplotoffset package, which can be found and installed here (uncomment to run
> ):
. *findit mplotoffset
. 
. *Second, the "modern" scheme, which can be downloaded here (uncomment to run):
. *net install scheme-modern, from("https://raw.githubusercontent.com/mdroste/stata-scheme
> -modern/master/")
. 
. ******************
. *Preparatory Work*
. ******************
. 
. *Make variables lowercase, add numbers to labels
. rename *, lower

. numlabel, add

. 
. *weights
. gen w=teamweight

. 
. *Generate new network size variables where variable values match reported network size
. gen netpol=ncf710a-1
(573 missing values generated)

. gen netimp=ncf710b-1
(585 missing values generated)

. 
. *Generate full netsize variable along with condition indicator and variable labels
. gen netsize=.
(1,000 missing values generated)

. 
. replace netsize=netpol if netpol!=.
(427 real changes made)

. replace netsize=netimp if netimp!=.
(415 real changes made)

. 
. recode netpol .=. *=1, gen(netpcondition)
(391 differences between netpol and netpcondition)

. recode netimp .=. *=1, gen(neticondition)
(393 differences between netimp and neticondition)

. 
. gen condition_pol=.
(1,000 missing values generated)

. replace condition = 1 if netpc==1
(427 real changes made)

. replace condition = 0 if netic==1
(415 real changes made)

. 
. label define exp_cond 0 "Social" 1 "Politics"

. label values condition_p exp_cond

. 
. **********************
. *MAIN PAPER MATERIALS*
. **********************
. 
. *Summary Statistics
. sum netpol netimp, detail

                           netpol
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%            0              0
10%            0              0       Obs                 427
25%            2              0       Sum of wgt.         427

50%            4                      Mean            4.30445
                        Largest       Std. dev.      3.223455
75%            6             11
90%           10             11       Variance       10.39066
95%           11             11       Skewness        .696697
99%           11             11       Kurtosis       2.595862

                           netimp
-------------------------------------------------------------
      Percentiles      Smallest
 1%            0              0
 5%            1              0
10%            2              0       Obs                 415
25%            2              0       Sum of wgt.         415

50%            4                      Mean           3.990361
                        Largest       Std. dev.      2.492482
75%            5             11
90%            8             11       Variance       6.212467
95%           10             11       Skewness       1.043657
99%           11             11       Kurtosis       4.047008

. 
. **********************************
. *TABLE 1: Sample Difference Tests*
. **********************************
. 
. ttest netsize, by(condition)

Two-sample t test with equal variances
------------------------------------------------------------------------------
   Group |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
---------+--------------------------------------------------------------------
  Social |     415    3.990361    .1223511    2.492482    3.749855    4.230868
Politics |     427     4.30445    .1559939    3.223455    3.997836    4.611063
---------+--------------------------------------------------------------------
Combined |     842    4.149644    .0995607    2.888977    3.954227     4.34506
---------+--------------------------------------------------------------------
    diff |           -.3140882    .1989653               -.7046157    .0764393
------------------------------------------------------------------------------
    diff = mean(Social) - mean(Politics)                          t =  -1.5786
H0: diff = 0                                     Degrees of freedom =      840

    Ha: diff < 0                 Ha: diff != 0                 Ha: diff > 0
 Pr(T < t) = 0.0574         Pr(|T| > |t|) = 0.1148          Pr(T > t) = 0.9426

. ksmirnov netsize, by(condition) exact

Two-sample Kolmogorov–Smirnov test for equality of distribution functions

Smaller group             D     p-value      Exact
--------------------------------------------------
Social               0.0949       0.023
Politics            -0.0909       0.031
Combined K-S         0.0949       0.045      0.041

Note: Ties exist in combined dataset;
      there are 12 unique values out of 842 observations.

. *exact p-value reported in paper
. 
. **********************************
. *FIGURE 1: Network Size Histogram*
. **********************************
. 
. *Generate offset for overlapping histogram
. gen netpolhist=netpol+.1
(573 missing values generated)

. gen netimphist=netimp-.1
(585 missing values generated)

. 
. *Initial Graph
. twoway (hist netimphist, discrete freq fcolor(green%50) lcolor(none) gap(50) barwidth(.9
> )) ///   
>  (hist netpolhist, discrete freq fcolor(purple%70) lcolor(none) gap(50) barwidth(.9))

. 
. *Customized labels & scheme
. twoway (hist netimphist, discrete freq fcolor(green%50) lcolor(none) gap(50) barwidth(.9
> )) ///   
>  (hist netpolhist, discrete freq fcolor(purple%70) lcolor(none) gap(50) barwidth(.9)), /
> //        
>        legend(region(lwidth(thin) lpattern(solid)) title(Condition, size(small)) order(1
>  "Social" 2 "Politics" )) scheme(modern) xtitle(Reported Network Size) plotregion(lcolor
> (black)) xlabel(0 "0" 5 "5" 10 "10" 11 "10+")

. 
. graph export "figure1histogram.pdf", replace
file /Users/reillyj/Desktop/working/NSX/reproduce/figure1histogram.pdf saved as PDF
    format

. 
. **********************************
. *FIGURE 2: Predicted Network Size*
. **********************************
. 
. *Recode and label political interest
. *New variable: lower numbers==lower interest; higher numubers==higher interest
. recode newsint 7=. 1=4 2=3 3=2 4=1, gen(interest)
(1000 differences between newsint and interest)

. label define newinterest 1 "Hardly at all" 2 "Only now and then" 3 "Some of the time" 4 
> "Most of the time"

. numlabel newinterest, add

. label values interest newinterest

. 
. *Model
. *Censored count data - poisson interaction
. cpoisson netsize i.condition##i.interest [pw=w], ul(11)

initial:       log pseudolikelihood = -1841.7763
rescale:       log pseudolikelihood = -1841.7763
Iteration 0:   log pseudolikelihood = -1841.7763  
Iteration 1:   log pseudolikelihood =  -1841.543  
Iteration 2:   log pseudolikelihood =  -1841.543  

Censored Poisson regression                         Number of obs     =    829
                                                           Uncensored =    771
Limits: Lower =  0                                      Left-censored =      0
        Upper = 11                                     Right-censored =     58

                                                    Wald chi2(7)      = 125.29
Log pseudolikelihood = -1841.543                    Prob > chi2       = 0.0000

----------------------------------------------------------------------------------------
                       |               Robust
               netsize | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
-----------------------+----------------------------------------------------------------
         condition_pol |
             Politics  |  -1.880849   .4379841    -4.29   0.000    -2.739283   -1.022416
                       |
              interest |
 2. Only now and then  |   .0966741   .1789275     0.54   0.589    -.2540173    .4473656
  3. Some of the time  |   .0921717   .1414756     0.65   0.515    -.1851155    .3694588
  4. Most of the time  |   .3011858   .1318463     2.28   0.022     .0427718    .5595998
                       |
condition_pol#interest |
             Politics #|
 2. Only now and then  |   1.264977   .4710327     2.69   0.007     .3417696    2.188184
             Politics #|
  3. Some of the time  |   1.898567   .4532756     4.19   0.000     1.010163    2.786971
             Politics #|
  4. Most of the time  |   2.089269   .4418369     4.73   0.000     1.223284    2.955253
                       |
                 _cons |   1.185978   .1247843     9.50   0.000     .9414053    1.430551
----------------------------------------------------------------------------------------

. 
. *Calculate Marginal Predicted Values
. margins interest#condition

Adjusted predictions                                       Number of obs = 829
Model VCE: Robust

Expression: Predicted number of events, predict()

----------------------------------------------------------------------------------------
                       |            Delta-method
                       |     Margin   std. err.      z    P>|z|     [95% conf. interval]
-----------------------+----------------------------------------------------------------
interest#condition_pol |
     1. Hardly at all #|
               Social  |   3.273888   .4085299     8.01   0.000     2.473184    4.074592
     1. Hardly at all #|
             Politics  |   .4991387   .2095544     2.38   0.017     .0884196    .9098578
 2. Only now and then #|
               Social  |   3.606192   .4624358     7.80   0.000     2.699834    4.512549
 2. Only now and then #|
             Politics  |   1.947954   .2271498     8.58   0.000     1.502749    2.393159
  3. Some of the time #|
               Social  |   3.589991   .2393267    15.00   0.000      3.12092    4.059063
  3. Some of the time #|
             Politics  |   3.654164   .3501984    10.43   0.000     2.967787     4.34054
  4. Most of the time #|
               Social  |   4.424529   .1883579    23.49   0.000     4.055355    4.793704
  4. Most of the time #|
             Politics  |   5.449822   .2164491    25.18   0.000      5.02559    5.874055
----------------------------------------------------------------------------------------

. 
. *Base Plot
. marginsplot, recast(scatter) plot1opts(color(green)) plot2opts(symbol(triangle) color(pu
> rple)) ci1opt(color(green)) ci2opt(color(purple))

Variables that uniquely identify margins: interest condition_pol

. 
. *Final Plot
. mplotoffset, title("") offset(0.1) scheme(modern) recast(scatter) ytit(Predicted Network
>  Size) xlab(1 "Hardly at all" 2 "Only now and then" 3 "Some of the time" 4 "Most of the 
> time") xtit(Political Interest (Follow Public Affairs))  legend(region(lwidth(thin) lpat
> tern(solid)) title(Condition, size(small))) plotregion(lcolor(black)) scale(1.2) plot1op
> ts(color(green)) plot2opts(symbol(triangle) color(purple)) ci1opt(color(green)) ci2opt(c
> olor(purple))

  Variables that uniquely identify margins: interest condition_pol

. 
. graph export "figure2predicted.pdf", replace
file /Users/reillyj/Desktop/working/NSX/reproduce/figure2predicted.pdf saved as PDF
    format

. 
. 
. ********************
. *APPENDIX MATERIALS*
. ********************
. 
. ****************************************************************
. *TABLE A1: Multinomial Logit: Netsize by Experimental Condition*
. ****************************************************************
. 
. *Multinomial Logistic Regression
. mlogit netsize i.condition

Iteration 0:   log likelihood = -1907.2504  
Iteration 1:   log likelihood = -1888.2499  
Iteration 2:   log likelihood = -1887.9974  
Iteration 3:   log likelihood = -1887.9972  

Multinomial logistic regression                         Number of obs =    842
                                                        LR chi2(11)   =  38.51
                                                        Prob > chi2   = 0.0001
Log likelihood = -1887.9972                             Pseudo R2     = 0.0101

-------------------------------------------------------------------------------
      netsize | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
--------------+----------------------------------------------------------------
0             |
condition_pol |
    Politics  |    1.03716   .3192258     3.25   0.001     .4114885    1.662831
        _cons |  -1.450005   .2549059    -5.69   0.000    -1.949611   -.9503984
--------------+----------------------------------------------------------------
1             |
condition_pol |
    Politics  |   .6674179   .3166763     2.11   0.035     .0467437    1.288092
        _cons |  -1.303407   .2404168    -5.42   0.000    -1.774615   -.8321984
--------------+----------------------------------------------------------------
2             |  (base outcome)
--------------+----------------------------------------------------------------
3             |
condition_pol |
    Politics  |  -.2008479   .2379992    -0.84   0.399    -.6673178     .265622
        _cons |   .0243915   .1561854     0.16   0.876    -.2817263    .3305093
--------------+----------------------------------------------------------------
4             |
condition_pol |
    Politics  |  -.2305237   .2457334    -0.94   0.348    -.7121523    .2511049
        _cons |   -.076961   .1602468    -0.48   0.631    -.3910389    .2371169
--------------+----------------------------------------------------------------
5             |
condition_pol |
    Politics  |   .0207908    .266963     0.08   0.938    -.5024472    .5440287
        _cons |  -.5026289   .1809803    -2.78   0.005    -.8573437   -.1479141
--------------+----------------------------------------------------------------
6             |
condition_pol |
    Politics  |   .3518722    .293831     1.20   0.231    -.2240261    .9277704
        _cons |   -.960462    .211196    -4.55   0.000    -1.374399   -.5465254
--------------+----------------------------------------------------------------
7             |
condition_pol |
    Politics  |   .3825808   .4080131     0.94   0.348    -.4171101    1.182272
        _cons |    -1.8295   .2987788    -6.12   0.000    -2.415096   -1.243904
--------------+----------------------------------------------------------------
8             |
condition_pol |
    Politics  |   .3862505   .3653685     1.06   0.290    -.3298586     1.10236
        _cons |  -1.561236   .2667756    -5.85   0.000    -2.084106   -1.038365
--------------+----------------------------------------------------------------
9             |
condition_pol |
    Politics  |   1.022235   .7093946     1.44   0.150    -.3681529    2.412623
        _cons |  -3.295832   .5879436    -5.61   0.000    -4.448181   -2.143484
--------------+----------------------------------------------------------------
10            |
condition_pol |
    Politics  |   .8680885   .6340754     1.37   0.171    -.3746765    2.110853
        _cons |  -3.008155    .512197    -5.87   0.000    -4.012042   -2.004267
--------------+----------------------------------------------------------------
11            |
condition_pol |
    Politics  |   .9734471   .3280351     2.97   0.003     .3305101    1.616384
        _cons |  -1.504075   .2605785    -5.77   0.000      -2.0148   -.9933509
-------------------------------------------------------------------------------

. 
. ***********************************
. *FIGURE A1: Marignal Probabilities*
. ***********************************
. 
. *Calculate Marginal Effects
. margins, dydx(condition)

Conditional marginal effects                               Number of obs = 842
Model VCE: OIM

dy/dx wrt: 1.condition_pol

1._predict:  Pr(netsize==0), predict(pr outcome(0))
2._predict:  Pr(netsize==1), predict(pr outcome(1))
3._predict:  Pr(netsize==2), predict(pr outcome(2))
4._predict:  Pr(netsize==3), predict(pr outcome(3))
5._predict:  Pr(netsize==4), predict(pr outcome(4))
6._predict:  Pr(netsize==5), predict(pr outcome(5))
7._predict:  Pr(netsize==6), predict(pr outcome(6))
8._predict:  Pr(netsize==7), predict(pr outcome(7))
9._predict:  Pr(netsize==8), predict(pr outcome(8))
10._predict: Pr(netsize==9), predict(pr outcome(9))
11._predict: Pr(netsize==10), predict(pr outcome(10))
12._predict: Pr(netsize==11), predict(pr outcome(11))

----------------------------------------------------------------------------------
                 |            Delta-method
                 |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
-----------------+----------------------------------------------------------------
0.condition_pol  |  (base outcome)
-----------------+----------------------------------------------------------------
1.condition_pol  |
        _predict |
              1  |   .0596031   .0180573     3.30   0.001     .0242114    .0949948
              2  |   .0312971   .0173714     1.80   0.072    -.0027503    .0653445
              3  |  -.0359301   .0263074    -1.37   0.172    -.0874916    .0156314
              4  |  -.0665105   .0256209    -2.60   0.009    -.1167266   -.0162944
              5  |  -.0636268   .0244723    -2.60   0.009    -.1115917   -.0156619
              6  |  -.0197116   .0214153    -0.92   0.357    -.0616847    .0222616
              7  |   .0119523   .0187589     0.64   0.524    -.0248145    .0487191
              8  |   .0061454   .0125532     0.49   0.624    -.0184584    .0307493
              9  |   .0082165    .014289     0.58   0.565    -.0197895    .0362225
             10  |   .0091645     .00742     1.24   0.217    -.0053784    .0237074
             11  |   .0090968   .0081275     1.12   0.263    -.0068328    .0250264
             12  |   .0503032   .0172862     2.91   0.004     .0164229    .0841836
----------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.

. 
. *Base plot
. marginsplot, recast(scatter)

Variables that uniquely identify margins:

. 
. *Final schemed and styled plot
. marginsplot, scheme(modern) recast(scatter)  xlabel(0 "0" 1 "1" 2 "2" 3 "3" 4 "4" 5 "5" 
> 6 "6" 7 "7" 8 "8" 9 "9" 10 "10" 11 "10+") title("") yline(0, lp(dash) lc(maroon)) xtit(N
> etwork Size) ytit("Marginal Probability" " ") plotregion(lcolor(black)) yscale(range(-.1
> 15 .115))

Variables that uniquely identify margins:

. 
. graph export "figureA1mlogit.pdf", replace
file /Users/reillyj/Desktop/working/NSX/reproduce/figureA1mlogit.pdf saved as PDF format

. 
. 
. ****************************
. *TABLE A2: Censored Poisson*
. ****************************
. 
. *Censored count data - poisson interaction
. cpoisson netsize i.condition##i.interest [pw=w], ul(11)

initial:       log pseudolikelihood = -1841.7763
rescale:       log pseudolikelihood = -1841.7763
Iteration 0:   log pseudolikelihood = -1841.7763  
Iteration 1:   log pseudolikelihood =  -1841.543  
Iteration 2:   log pseudolikelihood =  -1841.543  

Censored Poisson regression                         Number of obs     =    829
                                                           Uncensored =    771
Limits: Lower =  0                                      Left-censored =      0
        Upper = 11                                     Right-censored =     58

                                                    Wald chi2(7)      = 125.29
Log pseudolikelihood = -1841.543                    Prob > chi2       = 0.0000

----------------------------------------------------------------------------------------
                       |               Robust
               netsize | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
-----------------------+----------------------------------------------------------------
         condition_pol |
             Politics  |  -1.880849   .4379841    -4.29   0.000    -2.739283   -1.022416
                       |
              interest |
 2. Only now and then  |   .0966741   .1789275     0.54   0.589    -.2540173    .4473656
  3. Some of the time  |   .0921717   .1414756     0.65   0.515    -.1851155    .3694588
  4. Most of the time  |   .3011858   .1318463     2.28   0.022     .0427718    .5595998
                       |
condition_pol#interest |
             Politics #|
 2. Only now and then  |   1.264977   .4710327     2.69   0.007     .3417696    2.188184
             Politics #|
  3. Some of the time  |   1.898567   .4532756     4.19   0.000     1.010163    2.786971
             Politics #|
  4. Most of the time  |   2.089269   .4418369     4.73   0.000     1.223284    2.955253
                       |
                 _cons |   1.185978   .1247843     9.50   0.000     .9414053    1.430551
----------------------------------------------------------------------------------------

. 
. *****************************
. *FIGURE A2: Marginal Effects*
. *****************************
. 
. *Calculate marginal effects
. margins, dydx(condition) by(interest)

Average marginal effects                                   Number of obs = 829
Model VCE: Robust

Expression: Predicted number of events, predict()
dy/dx wrt:  1.condition_pol
Over:       interest

---------------------------------------------------------------------------------------
                      |            Delta-method
                      |      dy/dx   std. err.      z    P>|z|     [95% conf. interval]
----------------------+----------------------------------------------------------------
0.condition_pol       |  (base outcome)
----------------------+----------------------------------------------------------------
1.condition_pol       |
             interest |
    1. Hardly at all  |  -2.774749   .4591402    -6.04   0.000    -3.674647   -1.874851
2. Only now and then  |  -1.658238   .5152125    -3.22   0.001    -2.668036     -.64844
 3. Some of the time  |    .064172   .4241653     0.15   0.880    -.7671767    .8955208
 4. Most of the time  |   1.025293   .2869301     3.57   0.000     .4629203    1.587666
---------------------------------------------------------------------------------------
Note: dy/dx for factor levels is the discrete change from the base level.

. 
. *Draw marginal effects plot (base)
. marginsplot

Variables that uniquely identify margins: interest

. 
. *Draw marginal effects plot (styled)
. marginsplot, scheme(modern) title("") xtit(Political Interest (Follow Public Affairs)) y
> tit(Effect on Predicted Network Size) plotregion(lcolor(black)) xlab(1 "Hardly at all" 2
>  "Only now and then" 3 "Some of the time" 4 "Most of the time") xscale(range(0.75 4.25))
>  yline(0, lp(dash) lc(maroon))

Variables that uniquely identify margins: interest

. 
. graph export "figureA2cpmarginal.pdf", replace
file /Users/reillyj/Desktop/working/NSX/reproduce/figureA2cpmarginal.pdf saved as PDF
    format

. 
end of do-file

. log close
      name:  <unnamed>
       log:  /Users/reillyj/GitHub/net_size_experiment/submission prep/NSX Log (Unformatte
> d).log
  log type:  text
 closed on:   4 Oct 2022, 11:34:10
------------------------------------------------------------------------------------------
